// tcpip_test.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <winsock.h>
#include <Windows.h>
#include "RFH630.h"


int _tmain(int argc, _TCHAR* argv[])
{
	
	char Ipaddress[] = "169.254.183.189";
	int port = 2112;
	unsigned char Work_Buffer[100];
	int Work_start = 1;
	int Work_length = 8;
	int Work_Errorcode;
	RFH630_TAGID Work_Id;


	while (1)
	{

		//read 
		printf("Start Reading... Start = %d, Length = %d \n\n", 0, 16);
		Work_Errorcode = RFH_Readbytes(Ipaddress, port, &Work_Id, Work_Buffer, 0, 16);

		if (Work_Errorcode)
		{
			printf("error = %1x  happened,please check read\n",Work_Errorcode);
		}
		else
		{
			printf("finish Reading \n\n");
			printf("Uid = ");
			for (int i = 0; i < UIDLENGTH; i++)
			{
				printf("%1x ", Work_Id.id[i]);
			}
			
			printf("\ndata = ");
			for (int i = 0; i < 16; i++)
			{
				printf("%1x ", Work_Buffer[i]);
				Work_Buffer[i] += 1;
			}
			printf("\n");

			//write
			//printf("Start Writing... Start = %d, Length = %d \n", Work_start, Work_length);
			//Work_Errorcode = RFH_Writebytes(Ipaddress, port, &Work_Id, Work_Buffer, Work_start, Work_length);
			//if (Work_Errorcode)
			//{
			//	printf("error = %1 happened, please check write\n", Work_Errorcode);
			//}
			//else
			//{
			//	printf("finish writing \n");
			//}
			
		}

		if (getchar() == 'c')
		{
			break;
		}

		printf("\n");
	}

}

